<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta
            name="viewport"
            content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"
        />
        <meta
            name="format-detection"
            content="telephone=no,email=no,date=no,address=no"
        />
        <title></title>
        <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
        <style>
            body {
                background-color: #03a9f4;
            }

            #frm-container {
                margin: 0 auto;
                width: 83%;
                height: 100%;
                border-radius: 20px;
                border: 2px solid white;
                padding: 5px 10px;
                background: white;
            }

            #footer {
                background: none;
                position: absolute;
                bottom: 0;
            }
        </style>
    </head>

    <body>
        <header class="aui-bar aui-bar-nav" id="aui-header">
            <div class="aui-pull-left aui-btn" onclick="close_win();">
                <span class="aui-iconfont aui-icon-left"></span>返回
            </div>
        </header>

        <div id="frm-container" class="aui-content-padded">
            <div
                class="aui-tab aui-margin-t-10 aui-margin-b-5 aui-font-size-18"
            >
                <div style="color: #03a9f4; margin: 0 auto">请设置性别</div>
            </div>
            <div
                class="aui-hr"
                style="
                    width: 90%;
                    margin: 0 auto;
                    border-top: 0.05rem solid #03a9f4;
                "
            ></div>
            <div class="aui-row aui-row-padded">
                <div class="aui-col-xs-6">
                    <img
                        id="boy-image"
                        src="../../image/boy_unselected.png"
                        style="
                            width: 7rem;
                            height: 7rem;
                            border-radius: 10%;
                            margin: 0 auto;
                            margin-top: 1rem;
                        "
                        onclick="boySelected();"
                    />
                </div>
                <div class="aui-col-xs-6">
                    <img
                        id="girl-image"
                        src="../../image/gir_unselected.png"
                        style="
                            width: 7rem;
                            height: 7rem;
                            border-radius: 10%;
                            margin: 0 auto;
                            margin-top: 1rem;
                        "
                        onclick="girSelected();"
                    />
                </div>
            </div>
            <section class="aui-content-padded">
                <div
                    id="frm-confirm"
                    class="aui-btn aui-btn-block aui-btn-info aui-btn-sm aui-font-size-18 aui-disabled"
                    active
                    style="margin-top: 3rem"
                    tapmode
                    onclick="gender_confirm_clicked();"
                >
                    确认
                </div>
                <div
                    class="aui-btn aui-btn-block aui-btn-info aui-btn-sm aui-font-size-18"
                    active
                    style="margin-top: 1rem; margin-bottom: 5rem"
                    onclick="close_win();"
                >
                    取消
                </div>
            </section>
        </div>
    </body>
    <script type="text/javascript" src="../../script/api.js"></script>
    <script>
        function close_win() {
            api.openWin({
                name: "MainMenu",
                url: "./../MainMenu.html",
                reload: true,
            });
        }
    </script>
    <!-- <script type="text/javascript">
    var user_id;
    var sex = "";
    apiready = function () {
        api.parseTapmode();
        user_id = api.pageParam.userID;
        $api.fixStatusBar($api.byId('aui-header'));
        $api.css($api.byId('frm-container'), 'height:' + (api.frameHeight - 48 - $api.offset($api.byId('aui-header')).h) * 1.3 + 'px;')
    }

    function gender_confirm_clicked() {

        console.log($api.byId('boy-image').src);
        img_url = $api.byId('boy-image').src;
        girl_img_url = $api.byId('girl-image').src;
        var tmp_name = img_url.substr(img_url.lastIndexOf('/') + 1);
        var tmp_2_name = girl_img_url.substr(girl_img_url.lastIndexOf('/') + 1);
        console.log(tmp_name);
        if (tmp_name == "boy_selected.png" || (tmp_2_name == "gir_selected.png")) {

            if(tmp_name == "boy_selected.png")
            {
                tmp_name = "boy";
            }
            else 
            {
                tmp_name = "girl";
            }

            api.ajax({
                url: $api.getStorage("api_url") + '/lansys/user/saveSex',
                method: 'post',
                timeout: 5,
                data: {
                    values: {
                        uid: user_id,
                        value: tmp_name
                    }
                }
            }, function (ret, err) {
                if (ret) {
                    api.toast({
                        msg: '性别设置成功！',
                        duration: 2000,
                        location: 'bottom'
                    });
                    //alert( JSON.stringify( ret ) );
                    close_win();
                } else {
                    //alert( JSON.stringify( err ) );
                    close_win();
                }
            });

        } else {
            api.toast({
                msg: '请先选择性别！',
                duration: 2000,
                location: 'bottom'
            });

        }
    }
    //add by gxl
    function boySelected() {
        //$api.attr($api.byId("boy-image'"), 'src',"../../../image/boy_selected.png");
        $api.byId('boy-image').src = "../../../image/boy_selected.png";
        $api.byId('girl-image').src = "../../../image/gir_unselected.png";
        sex = "男";
        sex = encodeURI(sex);
    }

    function girSelected() {
        $api.byId('girl-image').src = "../../../image/gir_selected.png";
        $api.byId('boy-image').src = "../../../image/boy_unselected.png";
        sex = "女";
        sex = encodeURI(sex);
    }

    function close_win() {
        //api.closeWin({});
        api.openWin({
            name: 'completeInfo_birthday',
            url: './birthday.html',
            pageParam: {
                userID: user_id,
                login_user_name: api.pageParam.login_user_name,
                login_password: api.pageParam.login_password,
            }
        });
    }
</script> -->
</html>
